package d0316;



import java.util.concurrent.TimeUnit;

public class Resource {
    public  void f(){
        System.out.println(Thread.currentThread().getName()+"f()is running.");
        try {
            TimeUnit.SECONDS.sleep(2);
        }
        catch (InterruptedException e){
            e.printStackTrace();
        }
   /*     public synchronized void g() {
            System.out.println(Thread.currentThread().getName()+"g()is running.");
            try {
                TimeUnit.SECONDS.sleep(2);
            }
            catch (InterruptedException e){
                e.printStackTrace();
            }  */
    }

    public static void main(String[] args) {
        Resource resource= new Resource();
        new Thread(()->resource.f()).start();
        new Thread(()->resource.f()).start();
    }
}